home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / demo / file / Extension.lha / boot.s < prev    next >
Encoding:
Text File  |  1992-09-03  |  3.5 KB  |  203 lines

  1. ; sorry for the scruffiness of this loader. i just wrote a DOS file
  2. ; reader, then bolted on a prewritten demo-startup, then hacked it to
  3. ; get all the regs right before entry.
  4.  
  5. _LVOOldOpenLibrary=-408
  6. _LVOSupervisor=-30
  7. _LVOAllocMem=-198
  8. _LVOFreeMem=-210
  9. _LVOOpen=-30
  10. _LVOClose=-36
  11. _LVORead=-42
  12. _LVODelay=-198
  13.  
  14. _custom    EQU    $DFF000
  15. intreqr    EQU    $1E
  16. dmacon    EQU    $96
  17. intreq    EQU    $9C
  18.  
  19. LIB_VERSION    EQU    $14
  20. MEMF_PUBLIC    EQU    1
  21. MEMF_CHIP    EQU    2
  22. MODE_OLDFILE    equ    1004
  23.  
  24. demo_size    equ    $71800
  25. music_size    equ    $31A00
  26.  
  27.     move.l    4.w,a6
  28.     lea    dosname(pc),a1
  29.     jsr    _LVOOldOpenLibrary(a6)
  30.     tst.l    d0
  31.     beq    exit
  32.     move.l    d0,a5
  33.  
  34.     move.l    #demo_size,d0
  35.     move.l    #MEMF_PUBLIC,d1
  36.     jsr    _LVOAllocMem(a6)    ; alloc mem for demo
  37.     move.l    d0,d7
  38.     beq    exit
  39.     move.l    d0,demo_mem
  40.  
  41.     exg.l    a5,a6
  42.     lea    demoname(pc),a0
  43.     move.l    a0,d1
  44.     move.l    #MODE_OLDFILE,d2
  45.     jsr    _LVOOpen(a6)
  46.     move.l    d0,d6
  47.     beq    free_demo
  48.     move.l    d0,d1
  49.     move.l    d7,d2
  50.     move.l    #demo_size,d3
  51.     jsr    _LVORead(a6)
  52.     move.l    d0,d5
  53.     move.l    d6,d1
  54.     jsr    _LVOClose(a6)
  55.     cmp.l    #demo_size-3000,d5
  56.     blt    free_demo
  57.  
  58.     exg.l    a5,a6
  59.     move.l    #music_size,d0
  60.     move.l    #MEMF_PUBLIC!MEMF_CHIP,d1
  61.     jsr    _LVOAllocMem(a6)    ; alloc mem for demo
  62.     move.l    d0,d7
  63.     beq    free_demo
  64.     move.l    d0,mus_mem
  65.  
  66.     lea    musicname(pc),a0
  67.     move.l    a0,d1
  68.     move.l    #MODE_OLDFILE,d2
  69.     exg.l    a5,a6
  70.     jsr    _LVOOpen(a6)
  71.     move.l    d0,d6
  72.     beq    free_music
  73.     move.l    d0,d1
  74.     move.l    d7,d2
  75.     move.l    #music_size,d3
  76.     jsr    _LVORead(a6)
  77.     move.l    d0,d5
  78.     move.l    d6,d1
  79.     jsr    _LVOClose(a6)
  80.     cmp.l    #music_size-3000,d5
  81.     blt    free_music
  82.  
  83.     move.l    #60,d1
  84.     jsr    _LVODelay(a6)
  85.  
  86.     exg    a5,a6
  87.     move.l    demo_mem,a0
  88.     bsr    relocate
  89.     lea    demo_addr(pc),a0
  90.     move.l    a1,(a0)
  91.     move.l    mus_mem,a0
  92.     bsr    relocate
  93.     move.l    a1,a5
  94.  
  95.     jsr    -132(a6) ; _LVOForbid
  96.     move.l    #1024,d0
  97.     moveq.l    #1,d1
  98.     jsr    -198(a6) ; _LVOAllocMem
  99.     tst.l    d0
  100.     beq.s    nomem
  101.     move.l    d0,-(sp)
  102.     move.l    d0,a4
  103.     move.l    #0,a6
  104.     move.l    #255,d0
  105. savevbr    move.l    (a6)+,(a4)+
  106.     dbra    d0,savevbr
  107.     lea    $dff000,a4
  108.     lea    tempcop(pc),a0
  109.     move.l    a0,$80(a4)
  110.     move.w    #$7fff,d0
  111.     move.w    $1c(a4),-(sp)
  112.     or.w    #$c000,(sp)
  113.     move.w    2(a4),-(sp)
  114.     or.w    #$8200,(sp)
  115.     movem.l    d0-d7/a0-a6,-(sp)
  116.     bsr    mainbit
  117.     movem.l    (sp)+,d0-d7/a0-a6
  118.     move.w    d0,$96(a4)
  119.     move.w    (sp)+,$96(a4)
  120.     move.w    d0,$9a(a4)
  121.     move.w    (sp)+,$9a(a4)
  122.     move.l    (sp),a4
  123.     move.l    #0,a6
  124.     move.l    #255,d0
  125. unsave    move.l    (a4)+,(a6)+
  126.     dbra    d0,unsave
  127.     move.l    4.w,a6
  128.     move.l    (sp)+,a1
  129.     move.l    #1024,d0
  130.     jsr    -210(a6) ; _LVOFreeMem
  131. nomem    lea    gfxname(pc),a1
  132.     jsr    -408(a6) ; _LVOOldOpenLibrary
  133.     move.l    d0,a1
  134.     move.l    $26(a1),$dff080
  135.     jsr    -414(a6) ; _LVOCloseLibrary
  136.     jsr    -138(a6) ; _LVOPermit
  137.     clr.l    d0
  138.     rts
  139. gfxname    dc.b 'graphics.library',0
  140.  even
  141. tempcop dc.l $1000200,$1800000,-2
  142.  
  143. free_music
  144.     move.l    4.w,a6
  145.     move.l    mus_mem,a1
  146.     move.l    #music_size,d0
  147.     jsr    _LVOFreeMem(a6)
  148.  
  149. free_demo
  150.     move.l    4.w,a6
  151.     move.l    demo_mem,a1
  152.     move.l    #demo_size,d0
  153.     jsr    _LVOFreeMem(a6)
  154.  
  155. exit    clr.l    d0
  156.     rts
  157.  
  158. mainbit    move.w    #%0000000111000000,_custom+dmacon
  159.     moveq.l    #9,d7
  160. loop    move.w    #%0000000000100000,_custom+intreq
  161. waitvbl    btst    #5,_custom+intreqr+1
  162.     beq.s    waitvbl
  163.     dbra    d7,loop
  164.     clr.w    $80
  165.     move.l    a5,a1
  166.     lea    mus_mem(pc),a2
  167.     move.l    a1,(a2)
  168.     add.l    #$0001A510,(a2)
  169.     jsr    (a1)    ; start music
  170.     move.l    demo_addr,a0
  171.     move.w    #$8080,_custom+dmacon
  172.     lea    table(pc),a1
  173.     move.l    mus_mem,a2
  174.     jmp    (a0)
  175.  
  176. relocate
  177.     lea    28(a0),a0    ; returns a1 = start addr
  178.     move.l    (a0)+,d7
  179.     add.l    d7,d7
  180.     add.l    d7,d7
  181.     move.l    a0,a1
  182.     move.l    a0,d6
  183.     lea    4(a0,d7.l),a0
  184.     move.l    (a0)+,d7
  185.     subq.l    #1,d7
  186.     bmi.s    norelocs
  187.     addq.w    #4,a0
  188. nxtreloc    move.l    (a0)+,d0
  189.     add.l    d6,0(a1,d0.l)
  190.     dbra    d7,nxtreloc
  191. norelocs    addq.w    #8,a0
  192.     rts    
  193.  
  194. demo_mem    dc.l    0
  195. demo_addr    dc.l    0
  196. mus_mem    dc.l    0
  197. table    dc.w    2,4,8,18,22,24,28,31,35,39,40,49,51,60,0,0
  198. dosname    dc.b    'dos.library',0
  199. demoname    dc.b    'main',0
  200. musicname    dc.b    'music',0
  201.  
  202.  
  203.